#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//card 4 = copper
//card 5 = silver
//card 6 = gold

void checkUpdateCoins(int p, struct gameState *post, int b) {
  struct gameState pre;
  memcpy (&pre, post, sizeof(struct gameState));

  int r, s;
  r = updateCoins(p, &pre, b);
  s = updateCoins(p, post, b);
  assert(r == s);

}

int main () {
  int numTests = 2000;

  int i, b, n, r, p, deckCount, discardCount, handCount;

  int k[10] = {adventurer, council_room, feast, gardens, mine,
         remodel, smithy, village, baron, great_hall};

  struct gameState G;

  printf ("Testing UpdateCoins.\n");

  printf ("RANDOM TESTS.\n");

  SelectStream(2);
  PutSeed(3);

  for (n = 0; n < numTests; n++) {
    for (i = 0; i < sizeof(struct gameState); i++) {
      ((char*)&G)[i] = floor(Random() * 256);
    }
    p = floor(Random() * 2);
    b = floor(Random() * 3);
    G.deckCount[p] = floor(Random() * MAX_DECK);
    G.discardCount[p] = floor(Random() * MAX_DECK);
    G.handCount[p] = floor(Random() * MAX_HAND);
    checkUpdateCoins(p, &G, b);
  }

  printf ("(Ran %d tests)\nALL TESTS OK\n", numTests);

  exit(0);
}

